<?php
/**
 * WP-Click-Tracker Contextual Help
 *
 * Contains the contextual help function.
 *
 * @author Eric Lamb <eric@ericlamb.net>
 * @package    wp-click-tracker
 * @version 0.4.1
 * @filesource
 * @copyright 2009 Eric Lamb.
 */

/**
 * Determines what to display for the contextual help.
 *
 * @param   string  $content	The initial contextual help string.
 * @return  string
 */
function wp_click_track_contextual_help($content){

	$plugin_data = get_plugin_data(__FILE__);

	$plugin_name = $plugin_data['Name'];
	$plugin_description = $plugin_data['Description'];

	if(substr($_SERVER['PHP_SELF'],-18) == 'wp-admin/index.php'){

		$content .= '<h5>Click Tracker</h5>';
		$content .= 'The Click Tracker widget shows a snapshot of recent activity (last 14 days).';
		
	}

	if(!isset($_REQUEST['page']) || $_REQUEST['page'] != 'wp-click-track/click-tracker.php'){
		return $content;
	} else {

		if(strpos($_SERVER['PHP_SELF'],'options-general.php') === FALSE){

			if(isset($_REQUEST['req'])){
				$content = '<h5>'.__('Add / Edit Click Track Links').'</h5>';
				$content .= __('Use the form below to modify an existing, or add a new, click tracked link. These are useful for placing on an external website.');
			} else {
				//default page
				$content = '<h5>'.__('Click Tracked Links').'</h5>';
				$content .= __('Displays all links ordered from highest click count.');
			}
		} else {
			return $content;
		}
	}

	if(isset($_REQUEST['link'])){

		if(isset($_REQUEST['req']) && $_REQUEST['req'] == 'edit'){

			$content = '<h5>Edit Click Track Link</h5>';
			$content .= 'You can change the attributes for the link below.';
			return $content;

		}
		$content = 'You\'re looking at the click details for a particular link here. Below is a breakdown of the page.';
		$content .= '<h5>Distributable Link</h5>';
		$content .= 'The Distributable Link is useful for adding links to external websites. Just copy the URL type you want to use from the below.';
		$content .= '<h5>Link Data</h5>';
		$content .= 'Link Data contains a basic list of basic stats.';
		$content .= '<h5>Top Referrers</h5>';
		$content .= 'Lists the pages link clicks came from.';
		$content .= '<h5>Individual Clicks</h5>';
		$content .= 'Lists a complete list of all clicks. If you click on the IP address you can view the click path for that IP address. This\'ll allow you to see all the links a particular IP address has clicked on.';
		$content .= '<h5>Clicks by Day</h5>';
		$content .= 'Total clicks by day of the week.';
		$content .= '<h5>Clicks by Hour</h5>';
		$content .= 'Total clicks by hour of the day.';

		return $content;
	}

	return $content;
}

add_filter('contextual_help', 'wp_click_track_contextual_help', 11, 2);
?>